package edu.unc.ils.util;

import java.util.Comparator;
import java.util.Map;

public class ValueComparator implements Comparator {

    Map base;
    public ValueComparator(Map base) {
        this.base = base;
    }

    public int compare(Object a, Object b) {

      if((Integer)base.get(a) < (Integer)base.get(b)) {
        return 1;
      } else if((Integer)base.get(a) == (Integer)base.get(b)) {
          return String.valueOf(a).compareTo(String.valueOf(b));
          //return ((String)a).compareTo((String)b);
      } else {
        return -1;
      }
    }
  }
